#!  /usr/bin/env pytreon
#ecoding=utf
from ..utils.db_utils import DBUtils
from pymysql import cursors
import traceback


class TemplateDetailsDao():
    @staticmethod
    def getAllByRequestId(request_id):
        try:
            sql = "select a.* from t_template_detail a where a.request_id = \'"+str(request_id)+"\' order by a.orderby"
            conn = DBUtils.get_connection_pool().connection()
            cursor=conn.cursor(cursor=cursors.DictCursor)
            cursor.execute(sql)
            return cursor.fetchall()
        except Exception as e:
            print('error where execute getAllByRequestId....rollback...')
            traceback.print_exc()
    # @staticmethod
    # def update(obj):
    #     try:
    #         cursor = conn.cursor(cursor=cursors.DictCursor)
    #         sql = "update t_template_url  set status = 5 , send_status=2 where id ="+str(obj['id'])
    #         cursor.execute(sql)
    #     except Exception as e:
    #         conn.rollback()
    #         print('error where execute update.....rollback..')
    #         traceback.print_exc()
    #     finally:
    #         conn.commit()